package com.iman.locker.manager;

import android.text.TextUtils;

import com.iman.dao.User;
import com.iman.locker.Constant;
import com.iman.locker.MyApp;

/**
 * 管理锁
 * 锁的类型，锁的状态，锁的密码等
 * Created by esirong on 2015/12/5.
 */
public class LockerManager implements ILockerManager {
    @Override
    public boolean isLocked() {
        return false;
    }

    @Override
    public void lockApp() {
        if(isInitPassword()){
            //打开锁定页面
        }
    }

    @Override
    public void unLockApp() {

    }

    @Override
    public void getLockType() {

    }

    @Override
    public boolean isInitPassword() {
        boolean isPasswordWasSet = false;
        //获取用户信息,检查用户的密码设置情况
        User user = MyApp.getInstance().getUser();
        if(user.getLockType() == null){
            return false;
        }
        int lockType = user.getLockType();
        switch (lockType) {
            case Constant.LOCK_TYPE_DRAW:
                if (!TextUtils.isEmpty(user.getPasswordDraw())) {
                    isPasswordWasSet = true;
                }
                break;
            case Constant.LOCK_TYPE_PIN:
                if (!TextUtils.isEmpty(user.getPasswordPin())) {
                    isPasswordWasSet = true;
                }
                break;
            default:
                isPasswordWasSet = false;
                break;
        }
        return isPasswordWasSet;
    }
}
